package com.nxbw.quality.check.controller;

import com.nxbw.quality.base.response.JsonResult;
import com.nxbw.quality.base.response.PageData;
import com.nxbw.quality.check.pojo.dto.CheckQuery;
import com.nxbw.quality.check.pojo.dto.CheckSaveParam;
import com.nxbw.quality.check.service.CheckService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/v1/quality/check")
public class CheckController {
    @Autowired
    private CheckService checkService;
    @GetMapping("/select")
    public JsonResult selectCheck(CheckQuery checkQuery) {
        log.debug("查询检查项: {}",checkQuery);
        PageData data = checkService.selectCheck(checkQuery);
        return JsonResult.ok(data);
    }
    @PostMapping("/save")
    public JsonResult insertCheck(CheckSaveParam checkSaveParam) {
        log.debug("保存检查项: {}",checkSaveParam);
        checkService.saveCheck(checkSaveParam);
        return JsonResult.ok();
    }

    @PostMapping("/delete/{id}")
    public JsonResult deleteCheck(@PathVariable Long id) {
        log.debug("删除检查项: {}",id);
        checkService.deleteCheck(id);
        return JsonResult.ok();
    }

}
